package org.NooLab.openNLP.bst;

import java.util.ArrayList;
import java.util.Vector;

import org.NooLab.utilities.strings.ArrUtilities;
import org.NooLab.utilities.files.DFutils;
import org.NooLab.utilities.strings.StringsUtil;





public class PoSTags {

	ArrayList<PoSTag> posTags = new  ArrayList<PoSTag>();
	
	ArrayList<String> hashT = new ArrayList<String> (); 
	
	DFutils filutil = new DFutils ();
	ArrUtilities arrutil = new ArrUtilities();
	StringsUtil strgutil = new StringsUtil();
	
	
	
	public PoSTags(){
		
	}
	
	public void importPoSTagsCatalog(String filename, String language){
		String str ;
		String[] row ;
		int bv,sv,tv, vi;
		PoSTag ptag;
		
		ArrayList<String>  filecontent ;
		
		
		if (filutil.fileexists(filename)==false){
			return;
			
		}
		filecontent = filutil.readFileintoVectorstringTable(filename);
		
		// now separating languages, BST - scores, creating "map"
		
		for (int i=0;i<filecontent.size();i++){
			
			
			
			
			str = filecontent.get(i) ;
			row = str.split("\t") ;
			
			// adding to posTags
			if ((row[0].contentEquals(language)) && (row.length>=5)){
				// tag is in col 1
				
				str = row[1].trim();
				
				// scores are at pos ...
				bv = _convert_str( row[2]);
				sv = _convert_str( row[3]); ;
				tv = _convert_str( row[4]);

				ptag = new PoSTag() ;
				
				ptag.b_score = bv;
				ptag.s_score = sv;
				ptag.t_score = tv;
				
				ptag.tagLabel = str ;
				
				posTags.add(ptag) ;
				hashT.add( str );
			} // language ok?
			
		} // i->
		bv=0;
	}
	
	private int _convert_str( String str){
		int vi;
		
		if (str.length() > 0) {
			vi = Integer.parseInt(str);
		} else {
			vi = 0;
		}
		return vi;
	}

	public ArrayList<PoSTag> getPosTags() {
		return posTags;
	}

	public void setPosTags(ArrayList<PoSTag> posTags) {
		this.posTags = posTags;
	}

	public ArrayList<String> getHashT() {
		return hashT;
	}

	public void setHashT(ArrayList<String> hashT) {
		this.hashT = hashT;
	}

	
}
